package com.qf.bigdata.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

//类似与Bean注解，往IoC 容器中放入一个对象
@Controller
//@Repository
//@Service
public class MyController {

    @Autowired
    @Qualifier("prestoJdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    @RequestMapping("/hello")
    @ResponseBody
    public String sayHello(){
        return "hello";
    }
    @RequestMapping("/getEvents")
    @ResponseBody
    public List<Map<String,Object>> getEvents(){
        //show schemas;show catalogs;
        List<Map<String,Object>> result=jdbcTemplate.queryForList("select * from ods_news.event limit 10");

        return result;
    }

}
